package com.linkhub.oms.dao.mpservice.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkhub.oms.dao.mapper.LocalProductSysBarCodeEntityMapper;
import com.linkhub.oms.dao.mpservice.ILocalProductSysBarCodeService;
import com.linkhub.oms.entity.LocalProductSysBarCodeEntity;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;


/**
 * <p>
 * 本地商品系统商品编码表 服务实现类
 * </p>
 *
 * @author Jaycle
 * @since 2024-05-04
 */
@Service
public class LocalProductSysBarCodeServiceImpl extends ServiceImpl<LocalProductSysBarCodeEntityMapper, LocalProductSysBarCodeEntity> implements ILocalProductSysBarCodeService {

    @Override
    public LocalProductSysBarCodeEntity queryLocalProductBarCode( String userId, String skuId ) {
        return lambdaQuery()
                .eq(LocalProductSysBarCodeEntity::getUserId, userId)
                .eq(LocalProductSysBarCodeEntity::getSkuId, skuId)
                .one();
    }

    @Override
    public void insertByUserIdAndSkuId( String userId, String skuId ) {
        LocalProductSysBarCodeEntity localProductSysBarCodeEntity = new LocalProductSysBarCodeEntity();
        localProductSysBarCodeEntity.setUserId(userId);
        localProductSysBarCodeEntity.setSkuId(skuId);
        localProductSysBarCodeEntity.setCreatedTime(LocalDateTime.now());
        localProductSysBarCodeEntity.setUpdateTime(LocalDateTime.now());

        super.save(localProductSysBarCodeEntity);
    }
}
